﻿using Microsoft.Xna.Framework;

namespace SaveTheQueen.Utils.Colision
{
    public class RectangleShape : BaseShape
    {
        public override bool Intersect(Component.Sprite a, Component.Sprite b)
        {
            BoundingBox bbA = CreateFromSprite(a);
            BoundingBox bbB = CreateFromSprite(b);
            ContainmentType ct = bbA.Contains(bbB);

            if (ct == ContainmentType.Intersects || ct == ContainmentType.Contains)
                return true;
            else
                return false;
        }

        private BoundingBox CreateFromSprite(Component.Sprite sprite)
        {   // 1 depth
            return new BoundingBox(new Vector3(sprite.Position, 0), new Vector3(sprite.Position + sprite.Size * sprite.Scale, 1));
        }
    }
}
